package com.community.process._1010.common.utils;

import java.util.HashMap;

/**
 * @author Zbs
 * @date 2023/10/10 14:20
 */
public class Maps<K, V> extends HashMap<K, V> {

    public Maps() {
        super(1);
    }


    public static <K, V> Maps<K, V> of() {
        return new Maps<>();
    }

    public static <K, V> Maps<K, V> of(K key, V value) {
        return of(true, key, value);
    }

    public static <K> Maps<K, Object> ofObj(K key, Object value) {
        return ofObj(true, key, value);
    }


    public static <K, V> Maps<K, V> of(boolean conditions,K key, V value) {
        return new Maps<K, V>().ofSet(conditions,key, value);
    }

    public static <K> Maps<K, Object> ofObj(boolean conditions,K key, Object value) {
        return new Maps<K,Object>().ofSet(conditions,key, value);
    }

    public Maps<K, V> ofSet(K key, V value) {
        ofSet(true, key, value);
        return this;
    }

    public Maps<K, V> ofSet(boolean conditions,K key, V value) {
        if (conditions) {
            super.put(key, value);
        }
        return this;
    }

}
